package org.ting.e_commerce.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.ting.e_commerce.model.User;

@Mapper
public interface UserMapper {
    @Options(useGeneratedKeys = true, keyProperty = "userId")
    @Insert("insert into user(phone, email, password, name) values (#{phone}, #{email}, #{password}, #{name})")
    boolean insertUser(User user);
    @Select("select * from user where user_id = #{userId}")
    User selectById(int userId);
    @Select("select * from user where email = #{email}")
    User selectByEmail(String email);
    @Select("select * from user where phone = #{phone}")
    User selectByPhone(String phone);

    boolean updateUserById(User user);
    boolean updateUserByEmail(User user);
}
